// pages/home/categoryChoose.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],

    //支出账单分类列表
    payList: [{
        title: "餐饮食材",
        childs: [{
            name: "三餐",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/food/mianshi.png?sign=33350da2a9cc84754be576f796486a6f&t=1600330941"
          },
          {
            name: "大餐",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/food/huoguo.png?sign=bd8a2311a14bfcf1810635b91580642d&t=1600331244"
          },
          {
            name: "食材",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/food/-fen-.png?sign=7ae3addbee621381b938b6652bf94218&t=1600331256"
          },
          {
            name: "水果",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/food/xigua.png?sign=50d626104101e7d23a5e85fd3e3ca8bc&t=1600331291"
          },
          {
            name: "下午茶",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/food/kafei.png?sign=872c3755ed893faaa98b1004a2085a5b&t=1600331306"
          },
          {
            name: "零食",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/food/quqi.png?sign=1f3d6f3e7141069d5d43ef15837a8861&t=1600331327"
          },
          {
            name: "饮料",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/food/yinliao.png?sign=f02aac4d05b79fa889a7fe3867abbad2&t=1600331346"
          }
        ]
      },

      {
        title: "衣服饰品",
        childs: [{
            name: "上衣",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/cloth/yifu.png?sign=7de20aaafd7f661b2acd885b1268d9d2&t=1600331821"
          },
          {
            name: "裤子",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/cloth/xiuxiankuzi.png?sign=1231436d493c47fc6df6216c2e7ea91e&t=1600542122"
          },
          {
            name: "裙子",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/cloth/qunzi.png?sign=efee023b2735153b79ed58aae98bef90&t=1600331855"
          },
          {
            name: "鞋子",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/cloth/xiezi.png?sign=87a9c9d86e6236fb658e1fd8af99a5f4&t=1600331865"
          },
          {
            name: "包包",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/cloth/baobao.png?sign=0277d2f3e0bc9a3eead559a0df1ee84d&t=1600331876"
          },
          {
            name: "饰品",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/cloth/huangguan.png?sign=7ae174bbe0e13d7fab969d71a0af8e82&t=1600331886"
          }
        ]
      },
      {
        title: "休闲娱乐",
        childs: [{
            name: "电影",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/play/icon-test.png?sign=bfa93202427e7aeb49d0bd2c7def830b&t=1600332033"
          },
          {
            name: "健身",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/play/jianshen.png?sign=ff09eecdad4c1060a8851c9eca28e3f7&t=1600332136"
          },
          {
            name: "出行",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/play/traffic.png?sign=17989424a52763ee62e09abdc76996e5&t=1600332152"
          },
          {
            name: "游戏",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/play/youxi.png?sign=55599e2ea3796b319522b7420ce45d2a&t=1600332165"
          }
        ]
      },
      {
        title: "学习工作",
        childs: [{
            name: "书籍",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/study/yuedu.png?sign=62181db158ac484157beb426061de729&t=1600332285"
          },
          {
            name: "用具",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/study/taideng.png?sign=011a499ca5a27c11b8f3295dc1a03c8f&t=1600332252"
          },
          {
            name: "比赛",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/study/jiangbei.png?sign=cdaf123dd9d77da22ca748f7f370ce75&t=1600332238"
          },
        ]
      },
      {
        title: "医疗美容",
        childs: [{
            name: "医院",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/medical/duosesvggeshiyimeitubiao-04.png?sign=1deef116d69085e6c40341e000e25da9&t=1600332392"
          },
          {
            name: "药品",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/medical/duosesvggeshiyimeitubiao-03.png?sign=069e00ee0e0f37119aae500f220d32e0&t=1600492848"
          },
          {
            name: "美容院",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/medical/duosesvggeshiyimeitubiao-21.png?sign=161fdef580dd28a548b68d6474d90065&t=1600332434"
          },
          {
            name: "化妆品",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/medical/duosesvggeshiyimeitubiao-11.png?sign=189903fc31fec4751d447e2c6869b5df&t=1600332405"
          },
          {
            name: "香水",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/medical/duosesvggeshiyimeitubiao-13.png?sign=7de84632fd034f6c7ac246e21ccd6495&t=1600332422"
          }
        ]
      }
    ],

    //收入账单分类列表
    incomeList: [{
        title: "职业收入",
        childs: [{
            name: "工资收入",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/income/tubiaozhizuomoban.png?sign=8019fb76926163f0cd3be9615142e880&t=1600412748"
          },
          {
            name: "绩效奖金",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/income/jiaban.png?sign=2e58fd6c63a15a1428b451d269d72163&t=1600412711"
          },
          {
            name: "利息收入",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/income/qiandai.png?sign=ab4459cb5e801a05a9075770543da06e&t=1600412767"
          },
          {
            name: "投资收入",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/income/faqirentouzi.png?sign=6f84abc102bf82bdb44a00cb9f644923&t=1600412649"
          }
        ]
      },

      {
        title: "其他收入",
        childs: [{
            name: "中奖收入",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/income/bhjaward.png?sign=63fa4df438178cf440c0ab8bf77aac4b&t=1600412578"
          },
          {
            name: "红包收入",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/income/hongbao-qian-jiangjin-fuli.png?sign=412c81c71097f6576d820e6e7f391c84&t=1600412668"
          },
          {
            name: "意外来财",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/income/icon-test.png?sign=ef069d1800e1258c6cfbe6cffdbdb994&t=1600412683"
          }
        ]
      }
    ]

  },

  //选中分类并返回上一页
  returnCategory(event){
    var imgPath = event.currentTarget.dataset.imgPath
    var cateName = event.currentTarget.dataset.cateName
    var categoryTitle = event.currentTarget.dataset.title
    console.log("categoryTitle:"+categoryTitle)
    
    var pages = getCurrentPages();
    
    var currPage = pages[pages.length-1];

    var prevPage = pages[pages.length-2];

    if (this.data.choosedID == 0) {
      prevPage.setData({
        choosed_cate1: cateName,
        cateImg_path1: imgPath
      })
    }
    else if (this.data.choosedID == 1) {
      prevPage.setData({
        choosed_cate2: cateName,
        cateImg_path2: imgPath
      })
    }
    
    

    wx.navigateBack({
      //返回上一级
      delta: 1,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var choosedId = options.id;
    this.setData({
      choosedID: options.id
    })

    if(choosedId==0){
      this.setData({
        list:this.data.payList
      })
    }
    if(choosedId==1){
      this.setData({
        list:this.data.incomeList
      })
    }

    wx.setNavigationBarTitle({
      title: '选择分类',
    })
  },

})